<template>
	<view>
		<view class="nav-bar">
			<view class="bar-text" @click="goBack">
				<view class="align">

				</view>
				<text>返回</text>
			</view>
		</view>
		<view class="head">
			<scroll-view scroll-x class="bg-white nav">
				<view class="flex text-center">
					<view class="cu-item flex-sub" :class="index==TabCur?'text-red cur':''" v-for="(item,index) in list"
						:key="index" @tap="tabSelect" :data-id="index">
						{{item.name}}
					</view>
				</view>
			</scroll-view>
			<view class="card-menu" v-for="(item,index) in AllList" :key="index" @click="detail(item.id)">
				<view class="card-head">
					<text>订单编号：{{item.orderSn}}</text>
					<!-- <text class="card-head-goods" v-if="item.status== 2 ">未发货</text> -->
					<text class="card-head-goods" style='color: #eb2444;'>{{item.orderStatusText}}</text>
				</view>
				<view class="card-content">
					<image :src="item.goodsList[0].picUrl" mode=""></image>
					<view class="card-content-text" v-if="item.goodsList.length<2">
						<text class="Trygoods">{{item.goodsList[0].goodsName}}</text>
						<view class="Product">
							<text>{{item.goodsList[0].specifications[0]}}</text>
						</view>
						<text class="Goods-num">x{{item.goodsList[0].number}}</text>
					</view>
				</view>
				<view class="content-text-bot">
					<text class="money">合计:￥{{item.actualPrice}}.00(含运费)</text>
				</view>
				<view class="footer">
					
				</view>
			</view>
		</view>
		
		<view class="footer-text">
			没有更多了
		</view>
	</view>
</template>

<script>
	import api from '../../static/request.js'
	export default {
		data() {
			return {
				isCard: false,
				TabCur: 0,
				status: '',
				scrollLeft: 0,
				list: [{
					name: '全部'
				}, {
					name: '待支付'
				}, {
					name: '待发货'
				}, {
					name: '待收货'
				}, {
					name: '待评价'
				}, ],
				AllList: [],
			}
		},
		onShow() {
			this.getFirst()
		},
		onLoad(option) {
			console.log(option, '传递过来的参数')
			this.TabCur = option.sts
			// this.tabSelect(val)
		},
		methods: {
			// 
			detail(val){
				uni.navigateTo({
					url:'/pages/order-detail/order-detail?orderId='+val
				})
			},
			goBack(){
			    uni.switchTab({
			    	url:'/pages/mine/mine'
			    })	
			},
			// 调取全部接口
			tabSelect(e) {
				this.TabCur = e.currentTarget.dataset.id;
				this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60;
				// console.log(this.TabCur)
				api.get('order/list?', {
					showType: this.TabCur,
					page: 1,
					limit: 10,
				}).then(res => {
					console.log(res, '6666');
					uni.showLoading({
						title: '加载中...'
					});
					// 模拟异步数据请求
					setTimeout(() => {
						// 假设数据请求成功
						this.AllList = res.data.data.list;
						console.log(this.AllList, '8888888888')
						// 隐藏加载提示
						uni.hideLoading();
					}, 200);
				});
			},
			// 获取全部的列表
			getFirst() {
				console.log(this.TabCur)
				api.get('order/list?', {
					showType: this.TabCur,
					page: 1,
					limit: 10,
				}).then(res => {
					console.log(res, '6666');
					uni.showLoading({
						title: '加载中...'
					});
					// 模拟异步数据请求
					setTimeout(() => {
						// 假设数据请求成功
						this.AllList = res.data.data.list;
						console.log(this.AllList, '8888888888')
						// 隐藏加载提示
						uni.hideLoading();
					}, 200);
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import url("orderList.css");
</style>